package com.webchat.ugc.controller;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.request.MomentSaveOrUpdateVO;
import com.webchat.domain.vo.response.moment.MomentDetailVO;
import com.webchat.rmi.ugc.MomentClient;
import com.webchat.ugc.service.moment.MomentService;
import com.webchat.ugc.service.moment.MomentTimeLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class MomentController implements MomentClient {


    @Autowired
    private MomentService momentService;

    @Autowired
    private MomentTimeLineService momentTimeLineService;

    @Override
    public APIResponseBean<Long> publish(@RequestBody MomentSaveOrUpdateVO momentSaveOrUpdate) {

        Long momentId = momentService.publish(momentSaveOrUpdate);
        return APIResponseBeanUtil.success(momentId);
    }

    @Override
    public APIResponseBean<List<MomentDetailVO>> timeline(String userId, Long lastMomentId, Integer size) {
        List<MomentDetailVO> timeline = momentTimeLineService.timeline(userId, lastMomentId, size);
        return APIResponseBeanUtil.success(timeline);
    }
}
